﻿<%
'打开访问权限，用于访问控制
hu_access = True
%><!--#include file="h.asp"--><%
'
'	七色虎建站系统
'	会员注册页面
'	2011.11.2

Sub main
	Dim a,r,url,body_,code_,rs
	Dim name,pass,count,ip_,limit_
	a=getData("a")
	url=getData("_u")'返回地址
	hu.title = "会员注册"
	body_ = ""
	If a="" or bbsReg=0 Then
		code_=getCheckCode
		body_ = body_ & "[div=nav]会员注册-<a href="""&http_path&"bbs_login.asp?_u="&url&""">登录</a>[/div]"
		If bbsAgree<>"" Then body_ = body_ & ubbcode(bbsAgree) &"<br/>"
		If bbsReg=0 Then body_ = body_ & "[div=tip]网站暂停注册新会员[/div]"
		Dim formarray(4)
		formarray(0) = http_path&"bbs_reg.asp?a=1||post||提交||用户名：<br/>"
		formarray(1) = "input||name$$$$20$$16||<br/>密码：<br/>"
		formarray(2) = "input||pass$$$$20$$16||<br/>验证码："&code_&"<br/>"
		formarray(3) = "input||num1$$$$20||<br/>"
		formarray(4) = "hidden||num2$$"&numEncode(code_)&"||_u$$"&url&"||"
		body_ = body_ & hu.getForm(formarray) &" <a href="""&http_path&"bbs_login.asp?_u="&url&""">会员登录</a><br/>"&_
			"[div=tip]温馨提示：<br/>1.用户名不能以数字开头<br/>2.用户名不要含有敏感词<br/>3.用户名密码长度2~16位[/div]"
		Set rs=hu.conn("select top 3 id,name,regtime from 74hu_user order by id desc")
		If Not rs.eof Then
			body_ = body_ & "最新注册:<br/>"
			While Not rs.eof
				body_ = body_ & getDiffFromNow(rs("regtime"))&"，"& hu.url("bbs_user.asp?id="&rs("id"),rs("name"))&"注册<br/>"
				rs.movenext
			Wend
			body_ = body_ & "..."
		End If
	Else
		If getData("num1")<>numDecode(getData("num2")) Then rupt "错误", "验证码错误！"
		name=getD("name","")
		pass=getD("pass","")
		ip_=User_ip
		limit_=bbsRegLimit
		If limit_="" Or IsNumeric(limit_)=False Then limit_ = "0"
		If name="" or pass="" Then rupt "错误",  "用户名和密码不能为空！"
		If IsNumeric(left(name,1)) Then rupt "错误",  "用户名不能以数字开头！"
		If len(name)>16 Or len(pass)>16 Then rupt "错误",  "用户名和密码最长16位！"
		If len(name)<2 Or len(pass)<2 Then rupt "错误",  "用户名和密码最短2位！"
		If limit_ <>"0" Then
			Set rs = hu.conn("select top 1 name from 74hu_user where regip='"&ip_&"' And (regtime>#"&dateadd("h", -limit_, time_now)&"#) order by id desc")
			If Not rs.eof Then
				rupt "错误",  "温馨提示：您在"&limit_&"个小时内已注册过帐号"""&rs("name")&"""，请不要重复注册。<br/><br/>您的IP是"&ip_ &_
					"<br/><br/>如果有问题，请与管理员联系！"
			End If
		End If
		count = hu.conn("select count(id) from 74hu_user where name='"&name&"'")(0)
		If count<>"0" Then rupt "错误",  "用户名"""&name&"""已存在！请选择其他用户名"
		sid=getOnlySid()'登录时生成正确的唯一sid
		hu.conn("insert into 74hu_user ([name],[password],[regtime],[sid],[regip],[hu_level],[money],[sex],[topic],[reply]) values ('"&name&"','"&pass&"','"&time_now&"','"&sid&"','"&ip_&"',0,0,0,0,0)")
		If amtReg<>"" Then
			Set rs=hu.conn("select top 1 id from 74hu_user where name='"&name&"'")
			If Not rs.eof Then
				userid=rs("id")
				Call setUserAmount(userid, amtReg)'加金币积分经验
			End If
		End If
		body_ = body_ & "注册成功，请牢记您的注册信息<br/>用户名："&name&"<br/>密码："&pass
		body_ = body_ & "<br/><a href="""&http_path&"bbs_login.asp?_u="&url&""">验证登录</a><br/>"
	End If
	Set rs = Nothing
	hu.body = comUbb(body_)
End Sub

%>